<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../lib/vue.js"></script>
    <style>
        .red {
            background-color: red
        }

        .thin {
            font-weight: 100
        }

        .italic {
            font-style: italic
        }

        .active {
            letter-spacing: 1em
        }
    </style>
</head>

<body>
    <div id="app">
        <!-- v-for 使用 -->
        <p v-for="(item,i) in list">{{item}}---{{i}}</p>
        <!-- v-for 遍历对象数组 -->
        <!-- 必须使用key  key为数字或字符串  使用v-bind绑定 -->
        id:<input type="text" v-model="id"/>
        name:<input type="text" v-model="name"/>
        <input type="button" @click="add"/>

        <p v-for="user in userList" :key="user.id">
            <input type="checkbox"/>
        {{user.id}}============{{user.name}}
        </p>
        <!-- v-for 遍历单个对象 值、键、索引-->
        <p v-for="(v,k,i) in user">{{v}}</p>
        <!-- v-for 遍历数字 从1开始 -->
        <p v-for="i in 10">{{i}}</p>
    </div>
    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                id:'',
                name:'',
                list: [1, 2, 3, 4, 5],
                userList:[
                    {id:1,name:'tom'},
                    {id:2,name:'ddd'},
                    {id:3,name:'ttt'},
                ],
                user:{
                    id:1,
                    name:'test',
                    age:11
                }
            },
            methods: {
                
                add(){
                    
                    this.userList.unshift({id:this.id,name:this.name});
                }
            }
        })
    </script>

</body>

</html>